home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7023 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  94 lines

  1. Path: news.interlog.com!news
  2. From: kingkaos@interlog.com (King Kaos)
  3. Newsgroups: comp.lang.c
  4. Subject: Why won't this compile????
  5. Date: 17 Feb 1996 16:41:01 GMT
  6. Organization: Interlog
  7. Message-ID: <4g50et$9lh@steel.interlog.com>
  8. NNTP-Posting-Host: kingkaos.interlog.com
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13.  
  14.     Hi.  Can someone please explain why this program won't
  15. compile without errors?  I am using Power C under DOS.
  16.  
  17.  
  18. Heres the ANSI-C code:
  19.  
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22.  
  23. void swap(int *, int *);
  24.  
  25. main()
  26. {
  27.     int var1, var2;
  28.  
  29.     var1 = 25;
  30.     var2 = 99;
  31.     printf("Variables before swap");
  32.     printf("var1 = %d , var2 = %d\n",var1,var2);
  33.  
  34.     swap(&var1, &var2);
  35.     printf("Variables after swap");
  36.     printf("var1 = %d , var2 = %d\n,var1,var2);
  37. }
  38.  
  39. void swap(int *ptr1,int *ptr2)
  40. {
  41.     int temp;
  42.     temp = *ptr1;
  43.     *ptr1 = *ptr2;
  44.     *ptr2 = temp;
  45. }
  46.  
  47. -----------------------------
  48. And, heres the C.ERR file:
  49.  
  50. pointc~1.txt(18):}
  51. ****************                ^202
  52.       202: String constant cannot span lines
  53. ------------------------------------------------------------
  54. pointc~1.txt(20):void swap(int *ptr1,int *ptr2)
  55. **************** ^  4, 14           ^  6    ^104,222,  6,104,222
  56.         4: ')' expected
  57.        14: ';' expected
  58.         6: Illegal symbol
  59.       104: Undeclared identifier
  60.       222: Warning - Pointer does not match scalar (int, long, etc)
  61. ------------------------------------------------------------
  62. pointc~1.txt(21):{
  63. **************** ^ 14
  64.        14: ';' expected
  65. ------------------------------------------------------------
  66. pointc~1.txt(23):        temp = *ptr1;
  67. ****************                     ^104,141
  68.       104: Undeclared identifier
  69.       141: Type of variable is not pointer
  70. ------------------------------------------------------------
  71. pointc~1.txt(24):        *ptr1 = *ptr2;
  72. ****************              ^104,141,104,141
  73.       104: Undeclared identifier
  74.       141: Type of variable is not pointer
  75. ------------------------------------------------------------
  76. pointc~1.txt(25):        *ptr2 = temp;
  77. ****************              ^104,141
  78.       104: Undeclared identifier
  79.       141: Type of variable is not pointer
  80. ------------------------------------------------------------
  81. pointc~1.txt(26):}
  82. ****************  ^  9
  83.         9: Right braces expected
  84. ------------------------------------------------------------
  85.  
  86.  
  87. Any help will be appericated.  Please email respones directly to
  88. me.  Thank's.
  89.  
  90.  
  91.  
  92.         KING KAOS
  93.  
  94.